Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demonstrate GPIO interrupts on the LPC55S69-EVK board. #1919

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

lzrd
Copy link
Contributor

@lzrd lzrd commented Nov 17, 2024

Pressing the USER button generates an interrupt to the button task.

A single press will increment the RGB pattern.

Quick (~1.5s) successive presses 2nd, 3rd, and subsequent will respecitvely

  • turn off LEDs
  • blink LEDs
  • cycle through RBG pattern including all off.

Minor updates to other app.toml files:

  • add pint and inputmux peripherals to their gpio_driver tasks.
  • when compiling all targets, some needed slight allocation adjustments not related to this PR.

drv/lpc55-gpio/src/main.rs Outdated Show resolved Hide resolved
drv/lpc55-gpio/src/main.rs Outdated Show resolved Hide resolved
};

// XXX for now at least, setting up a PINT pin will set dir to Input
server.gpio.disable_rising(BUTTON_PINT_MASK);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these calls are redundant with the reset state of the PINT peripheral and can be removed.

@lzrd
Copy link
Contributor Author

lzrd commented Nov 17, 2024

Note: This implementation only implements edge-detection interrupts and ignores level-detection.

aapoalas

This comment was marked as off-topic.

@lzrd lzrd force-pushed the button-demo branch 2 times, most recently from 8b12ea1 to 6dd78e5 Compare November 18, 2024 03:39
build/lpc55pins/src/lib.rs Outdated Show resolved Hide resolved
drv/lpc55-gpio/src/main.rs Outdated Show resolved Hide resolved
drv/lpc55-gpio/src/main.rs Outdated Show resolved Hide resolved
fn set_pin_direction(&self, port: usize, pin: usize, dir: Direction) {
match dir {
Direction::Input => self.gpio.dirclr[port]
.write(|w| unsafe { w.dirclrp().bits(1 << pin) }),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unsafe is a quirk of how the lpc55-pac is generated. Adding a safety comment for this is unlikely to be useful.

@lzrd lzrd force-pushed the button-demo branch 2 times, most recently from 2ae073d to 1e52c42 Compare November 19, 2024 03:19
lzrd added 4 commits November 25, 2024 19:47
Add interrupt-related API calls to the LPC55 `gpio_driver`.

A task on an LPC55 can now configue and use GPIO interrupts.

app.toml example shows Pin Interrupt configuration:

[tasks.foo]
...
interrupts = { "pint.irq0" = "button-irq" }
...
task-slots = ["gpio_driver", ...]

[tasks.foo.config]
pins = [
  { name="BUTTON', pin={ port=1, pin=9}, alt=0, pint=0, direction="input", opendrain="normal" }
]
…API.

The functions:

fn {clear,detected,disable,enable}_{rising,falling,status}(PintSlot)
and
fn read_pint_status(...)

become

fn pint_op(PintSlot, PintOp, PintCondition)

This leaves a couple permutations not covered (enable/disable
interrupt at the NVIC level).
Those can are left as no-ops for the time being.

Future: The unimplemented combinations could return an error/fault
if called.
Pressing the USER button generates an interrupt to the button task.

A single press will increment the RGB pattern.

Quick (~1.5s) successive presses 2nd, 3rd, and subsequent will respecitvely
  - turn off LEDs
  - blink LEDs
  - cycle through RBG pattern including all off.

Minor updates to other app.toml files:
  - add `pint` and `inputmux` peripherals to their `gpio_driver` tasks.
  - when compiling all targets, some needed slight allocation
    adjustments not related to this PR.

Future: The unimplemented combinations could return an error/fault if called.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants